/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "composition")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Composition.findAll", query = "SELECT c FROM Composition c"),
    @NamedQuery(name = "Composition.findByCompositionId", query = "SELECT c FROM Composition c WHERE c.compositionId = :compositionId"),
    @NamedQuery(name = "Composition.findByCompositionIdByActive", query = "SELECT c FROM Composition c WHERE c.compositionId = :compositionId AND c.active = :active"),
    @NamedQuery(name = "Composition.findByProviderIdByProductIdByActive", query = "SELECT c FROM Composition c WHERE c.product.productPK.providerId = :providerId AND c.product.productPK.productId = :productId AND c.active = :active"),
    @NamedQuery(name = "Composition.deleteByProviderIdByProductId", query = "DELETE FROM Composition c WHERE c.product.productPK.providerId = :providerId AND c.product.productPK.productId = :productId"),
    @NamedQuery(name = "Composition.findByName", query = "SELECT c FROM Composition c WHERE c.name = :name"),
    @NamedQuery(name = "Composition.findByQuantity", query = "SELECT c FROM Composition c WHERE c.quantity = :quantity"),
    @NamedQuery(name = "Composition.findByActive", query = "SELECT c FROM Composition c WHERE c.active = :active")})
public class Composition implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "compositionId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer compositionId;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "quantity")
    private String quantity;
    @Column(name = "checkHealth")
    private String checkHealth;
    @Column(name = "detailCheckHealth")
    private String detailCheckHealth;
    @Column(name = "valueRadio")
    private Integer valueRadio;
    @Basic(optional = false)
    @Column(name = "active")
    private boolean active;    
	@JoinColumn(name = "typeCompositionId", referencedColumnName = "typeCompositionId")
    @ManyToOne
    private Typecomposition typeCompositionId;
    @JoinColumns({
        @JoinColumn(name = "providerId", referencedColumnName = "providerId"),
        @JoinColumn(name = "productId", referencedColumnName = "productId")})
    @ManyToOne
    private Product product;

    public Composition() {
    }

    public Composition(Integer compositionId) {
        this.compositionId = compositionId;
    }

    public Composition(Integer compositionId, String name, String quantity, boolean active) {
        this.compositionId = compositionId;
        this.name = name;
        this.quantity = quantity;
        this.active = active;
    }

    public Integer getCompositionId() {
        return compositionId;
    }

    public void setCompositionId(Integer compositionId) {
        this.compositionId = compositionId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getCheckHealth() {
		return checkHealth;
	}

	public void setCheckHealth(String checkHealth) {
		this.checkHealth = checkHealth;
	}
	public String getDetailCheckHealth() {
		return detailCheckHealth;
	}

	public void setDetailCheckHealth(String detailCheckHealth) {
		this.detailCheckHealth = detailCheckHealth;
	}

	public Integer getValueRadio() {
		return valueRadio;
	}

	public void setValueRadio(Integer valueRadio) {
		this.valueRadio = valueRadio;
	}
    
    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Typecomposition getTypeCompositionId() {
        return typeCompositionId;
    }

    public void setTypeCompositionId(Typecomposition typeCompositionId) {
        this.typeCompositionId = typeCompositionId;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (compositionId != null ? compositionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Composition)) {
            return false;
        }
        Composition other = (Composition) object;
        if ((this.compositionId == null && other.compositionId != null) || (this.compositionId != null && !this.compositionId.equals(other.compositionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Composition[ compositionId=" + compositionId + " ]";
    }
    
}
